var a = getApp();

Page({
    data: {
        active: 2,
        info: {},
        amount: {},
        listData: [],
        status: 2,
        json: {},
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(a) {
        this.getdata();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (this.data.page >= this.data.total_page) this.setData({
            isLoadMore: !1
        }); else if (this.data.isLoadMore) {
            var a = this.data.page + 1;
            this.setData({
                page: a
            }), this.getMoreData();
        }
    },
    onShareAppMessage: function() {},
    change: function(a) {
        this.setData({
            json: {
                status: 2 == a.detail.name ? null : a.detail.name
            },
            active: a.detail.name,
            page: 1,
            total_page: 0,
            listData: [],
            isLoadMore: !0
        }), this.getdata();
    },
    getdata: function() {
        var t = this;
        wx.showLoading({
            title: "加载中"
        });
        var e = a.getNetAddresss("plugin.member-share-reward.Frontend.controllers.records.index");
        a._postNetWork({
            url: e,
            data: this.data.json,
            success: function(a) {
                var e = a.data;
                wx.hideLoading(), 1 == e.result ? t.setData({
                    info: e.data.info,
                    amount: e.data.amount,
                    listData: e.data.list.data,
                    total_page: e.data.list.last_page
                }) : wx.showToast({
                    title: e.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    },
    getMoreData: function() {
        var t = this;
        wx.showLoading({
            title: "加载中"
        }), this.setData({
            json: {
                page: this.data.page,
                status: 2 == this.data.active ? null : this.data.active
            }
        });
        var e = a.getNetAddresss("plugin.member-share-reward.Frontend.controllers.records.search");
        a._postNetWork({
            url: e,
            data: this.data.json,
            success: function(a) {
                var e = a.data;
                if (wx.hideLoading(), 1 == e.result) {
                    var s = e.data.data;
                    t.setData({
                        listData: t.data.listData.concat(s),
                        page: e.data.current_page,
                        last_page: e.data.last_page,
                        isLoadMore: !0
                    });
                } else {
                    var o = t.data.page - 1;
                    t.setData({
                        page: o,
                        isLoadMore: !1
                    }), wx.showToast({
                        title: e.msg,
                        duration: 1e3,
                        icon: "none"
                    });
                }
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    }
});